/**
 * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.liferay.library.model.impl;

import com.liferay.library.model.Publisher;
import com.liferay.library.model.PublisherModel;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import java.io.Serializable;

import java.lang.reflect.Proxy;

import java.sql.Types;

/**
 * The base model implementation for the Publisher service. Represents a row in the &quot;Library_Publisher&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link com.liferay.library.model.PublisherModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link PublisherImpl}.
 * </p>
 *
 * <p>
 * Never modify or reference this class directly. All methods that expect a publisher model instance should use the {@link com.liferay.library.model.Publisher} interface instead.
 * </p>
 *
 * @author Meanson Wang
 * @see PublisherImpl
 * @see com.liferay.library.model.Publisher
 * @see com.liferay.library.model.PublisherModel
 * @generated
 */
public class PublisherModelImpl extends BaseModelImpl<Publisher>
	implements PublisherModel {
	public static final String TABLE_NAME = "Library_Publisher";
	public static final Object[][] TABLE_COLUMNS = {
			{ "publisherId", new Integer(Types.BIGINT) },
			{ "companyId", new Integer(Types.BIGINT) },
			{ "groupId", new Integer(Types.BIGINT) },
			{ "name", new Integer(Types.VARCHAR) },
			{ "emailAddress", new Integer(Types.VARCHAR) },
			{ "website", new Integer(Types.VARCHAR) },
			{ "phoneNumber", new Integer(Types.VARCHAR) }
		};
	public static final String TABLE_SQL_CREATE = "create table Library_Publisher (publisherId LONG not null primary key,companyId LONG,groupId LONG,name VARCHAR(75) null,emailAddress VARCHAR(75) null,website VARCHAR(75) null,phoneNumber VARCHAR(75) null)";
	public static final String TABLE_SQL_DROP = "drop table Library_Publisher";
	public static final String ORDER_BY_JPQL = " ORDER BY publisher.name ASC";
	public static final String ORDER_BY_SQL = " ORDER BY Library_Publisher.name ASC";
	public static final String DATA_SOURCE = "liferayDataSource";
	public static final String SESSION_FACTORY = "liferaySessionFactory";
	public static final String TX_MANAGER = "liferayTransactionManager";
	public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.entity.cache.enabled.com.liferay.library.model.Publisher"),
			true);
	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.com.liferay.library.model.Publisher"),
			true);
	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
				"lock.expiration.time.com.liferay.library.model.Publisher"));

	public PublisherModelImpl() {
	}

	public long getPrimaryKey() {
		return _publisherId;
	}

	public void setPrimaryKey(long pk) {
		setPublisherId(pk);
	}

	public Serializable getPrimaryKeyObj() {
		return new Long(_publisherId);
	}

	public long getPublisherId() {
		return _publisherId;
	}

	public void setPublisherId(long publisherId) {
		_publisherId = publisherId;
	}

	public long getCompanyId() {
		return _companyId;
	}

	public void setCompanyId(long companyId) {
		_companyId = companyId;
	}

	public long getGroupId() {
		return _groupId;
	}

	public void setGroupId(long groupId) {
		_groupId = groupId;
	}

	public String getName() {
		if (_name == null) {
			return StringPool.BLANK;
		}
		else {
			return _name;
		}
	}

	public void setName(String name) {
		_name = name;
	}

	public String getEmailAddress() {
		if (_emailAddress == null) {
			return StringPool.BLANK;
		}
		else {
			return _emailAddress;
		}
	}

	public void setEmailAddress(String emailAddress) {
		_emailAddress = emailAddress;
	}

	public String getWebsite() {
		if (_website == null) {
			return StringPool.BLANK;
		}
		else {
			return _website;
		}
	}

	public void setWebsite(String website) {
		_website = website;
	}

	public String getPhoneNumber() {
		if (_phoneNumber == null) {
			return StringPool.BLANK;
		}
		else {
			return _phoneNumber;
		}
	}

	public void setPhoneNumber(String phoneNumber) {
		_phoneNumber = phoneNumber;
	}

	public Publisher toEscapedModel() {
		if (isEscapedModel()) {
			return (Publisher)this;
		}
		else {
			return (Publisher)Proxy.newProxyInstance(Publisher.class.getClassLoader(),
				new Class[] { Publisher.class }, new AutoEscapeBeanHandler(this));
		}
	}

	public ExpandoBridge getExpandoBridge() {
		if (_expandoBridge == null) {
			_expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
					Publisher.class.getName(), getPrimaryKey());
		}

		return _expandoBridge;
	}

	public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
		getExpandoBridge().setAttributes(serviceContext);
	}

	public Object clone() {
		PublisherImpl clone = new PublisherImpl();

		clone.setPublisherId(getPublisherId());
		clone.setCompanyId(getCompanyId());
		clone.setGroupId(getGroupId());
		clone.setName(getName());
		clone.setEmailAddress(getEmailAddress());
		clone.setWebsite(getWebsite());
		clone.setPhoneNumber(getPhoneNumber());

		return clone;
	}

	public int compareTo(Publisher publisher) {
		int value = 0;

		value = getName().compareTo(publisher.getName());

		if (value != 0) {
			return value;
		}

		return 0;
	}

	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		Publisher publisher = null;

		try {
			publisher = (Publisher)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		long pk = publisher.getPrimaryKey();

		if (getPrimaryKey() == pk) {
			return true;
		}
		else {
			return false;
		}
	}

	public int hashCode() {
		return (int)getPrimaryKey();
	}

	public String toString() {
		StringBundler sb = new StringBundler(15);

		sb.append("{publisherId=");
		sb.append(getPublisherId());
		sb.append(", companyId=");
		sb.append(getCompanyId());
		sb.append(", groupId=");
		sb.append(getGroupId());
		sb.append(", name=");
		sb.append(getName());
		sb.append(", emailAddress=");
		sb.append(getEmailAddress());
		sb.append(", website=");
		sb.append(getWebsite());
		sb.append(", phoneNumber=");
		sb.append(getPhoneNumber());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(25);

		sb.append("<model><model-name>");
		sb.append("com.liferay.library.model.Publisher");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>publisherId</column-name><column-value><![CDATA[");
		sb.append(getPublisherId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>companyId</column-name><column-value><![CDATA[");
		sb.append(getCompanyId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>groupId</column-name><column-value><![CDATA[");
		sb.append(getGroupId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>name</column-name><column-value><![CDATA[");
		sb.append(getName());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>emailAddress</column-name><column-value><![CDATA[");
		sb.append(getEmailAddress());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>website</column-name><column-value><![CDATA[");
		sb.append(getWebsite());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>phoneNumber</column-name><column-value><![CDATA[");
		sb.append(getPhoneNumber());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private long _publisherId;
	private long _companyId;
	private long _groupId;
	private String _name;
	private String _emailAddress;
	private String _website;
	private String _phoneNumber;
	private transient ExpandoBridge _expandoBridge;
}